package com.mecuros.service;

import com.mecuros.model.Order;
import feign.Param;
import feign.QueryMap;
import feign.RequestLine;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.text.MessageFormat;
import java.util.List;

/**
 * @Classname OpenFeignService
 * @Description TODO
 * @Date 2022/2/8 10:59 下午
 * @Created by yujianbo
 */
@FeignClient(value = "openFeign-provider",fallback = OpenFeignFallbackService.class)
public interface OpenFeignService {

    @GetMapping("/openfeign/provider/test/{id}")
    String get(@PathVariable("id")Integer id);

    @PostMapping("/openfeign/provider/order1")
    Order createOrder1(@SpringQueryMap Order order);

    @PostMapping("/openfeign/provider/order2")
    Order createOrder2(@RequestBody Order order);

    @PostMapping("/openfeign/provider/order3")
    String batchOrder(@RequestBody List<Order> orders);

    /**
     * 必须要@RequestParam注解标注，且value属性必须填上参数名
     * 方法参数名可以任意，但是@RequestParam注解中的value属性必须和provider中的参数名相同
     */
    @PostMapping("/openfeign/provider/test2")
    String test(@RequestParam("id") String arg1, @RequestParam("name") String arg2);

//    @RequestLine("GET /openfeign/provider/test/{id}")
//    String test3(@Param("id") String id);
}
